package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.NewsAuthDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 霍森彪
 * @date 2022/7/15 16:44
 */
@RestController
@RequestMapping("/api/v1/news")
public class NewsController {


    @Autowired
    private WmNewsService wmNewsService;
    //查询自媒体文章
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmNewsPageReqDto dto){
        return wmNewsService.findList(dto);
    }

    @PostMapping("/submit")
    public ResponseResult submit(@RequestBody WmNewsDto dto) throws Exception {
        return wmNewsService.submit(dto);
    }

    /**
     * 文章上架下架
     * @param dto
     * @return
     */
    @PostMapping("/down_or_up")
    public ResponseResult upOrDown(@RequestBody WmNewsDto dto){
        return wmNewsService.upOrDown(dto);
    }

    /**
     * 查询需要人工审核的文章列表
     * @param dto
     * @return
     */
    @PostMapping("/list_vo")
    public ResponseResult newsList(@RequestBody NewsAuthDto dto){
        return wmNewsService.newsList(dto);
    }

    /**
     * news详情查看
     * @param newsId
     * @return
     */
    @GetMapping("/one_vo/{id}")
    public ResponseResult newsText(@PathVariable("id") Integer newsId){
        return wmNewsService.newsText(newsId);
    }

    /**
     * 文章审核驳回
     * @param dto
     * @return
     */
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto dto){
        return wmNewsService.authFail(dto);
    }

    /**
     * 文章审核通过
     * @param dto
     * @return
     */
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewsAuthDto dto){
        return wmNewsService.authPass(dto);
    }

}
